<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        var arr = [1, 22, 3, 47, 5, 16, 7, 331, 9, 10];
        // 求证数组的平均数
        // 先对数组元素  求和
        var sum = 0;
        for (var i = 0; i < arr.length; i++) {
            // sum = sum + arr[i];
            sum += arr[i];
        }
        // console.log(sum);
        var arg = sum / arr.length;
        console.log(arg)
    </script>
</body>

</html>